From e81ccb671014db62bf622cd8f960d7930d27d9dc Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Wed, 29 Jul 2020 17:29:14 +0800
Subject: [PATCH] build: only link libopenvswitch with libunwind, libunbound

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 lib/automake.mk          | 2 ++
 lib/libopenvswitch.pc.in | 2 +-
 m4/openvswitch.m4        | 6 ++++--
 3 files changed, 7 insertions(+), 3 deletions(-)

--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -10,6 +10,8 @@ lib_LTLIBRARIES += lib/libopenvswitch.la
 lib_libopenvswitch_la_LIBADD = $(SSL_LIBS)
 lib_libopenvswitch_la_LIBADD += $(CAPNG_LDADD)
 lib_libopenvswitch_la_LIBADD += $(LIBBPF_LDADD)
+lib_libopenvswitch_la_LIBADD += $(LIBUNBOUND_LDADD)
+lib_libopenvswitch_la_LIBADD += $(LIBUNWIND_LDADD)
 
 
 if WIN32
--- a/lib/libopenvswitch.pc.in
+++ b/lib/libopenvswitch.pc.in
@@ -7,5 +7,5 @@ Name: libopenvswitch
 Description: Open vSwitch library
 Version: @VERSION@
 Libs: -L${libdir} -lopenvswitch
-Libs.private: @LIBS@
+Libs.private: @LIBS@ @SSL_LIBS@ @CAPNG_LDADD@ @LIBBPF_LDADD@ @LIBUNBOUND_LDADD@ @LIBUNWIND_LDADD@
 Cflags: -I${includedir}/openvswitch
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -677,7 +677,8 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
   [AC_CHECK_LIB(unbound, ub_ctx_create, [HAVE_UNBOUND=yes], [HAVE_UNBOUND=no])
    if test "$HAVE_UNBOUND" = yes; then
      AC_DEFINE([HAVE_UNBOUND], [1], [Define to 1 if unbound is detected.])
-     LIBS="$LIBS -lunbound"
+     LIBUNBOUND_LDADD="-lunbound"
+     AC_SUBST(LIBUNBOUND_LDADD)
    fi
    AM_CONDITIONAL([HAVE_UNBOUND], [test "$HAVE_UNBOUND" = yes])
    AC_SUBST([HAVE_UNBOUND])])
@@ -689,7 +690,8 @@ AC_DEFUN([OVS_CHECK_UNWIND],
    [HAVE_UNWIND=no])
    if test "$HAVE_UNWIND" = yes; then
      AC_DEFINE([HAVE_UNWIND], [1], [Define to 1 if unwind is detected.])
-     LIBS="$LIBS -lunwind"
+     LIBUNWIND_LDADD="-lunwind"
+     AC_SUBST(LIBUNWIND_LDADD)
    fi
    AM_CONDITIONAL([HAVE_UNWIND], [test "$HAVE_UNWIND" = yes])
    AC_SUBST([HAVE_UNWIND])])
